//
//  OrientViewController.m
//  Intake
//
//  Created by vandong on 9/29/13.
//  Copyright (c) 2013 Mac Center. All rights reserved.
//

#import "OrientViewController.h"
#import "LanscapeViewController.h"

@interface OrientViewController ()
{
        LanscapeViewController *landscape;
}
@end

@implementation OrientViewController

- (id)initWithNibName:(NSString *)nibNameOrNil bundle:(NSBundle *)nibBundleOrNil
{
    self = [super initWithNibName:nibNameOrNil bundle:nibBundleOrNil];
    if (self) {
        // Custom initialization
        landscape = [LanscapeViewController new];
    }
    return self;
}

- (void)viewDidLoad
{
    [super viewDidLoad];
	// Do any additional setup after loading the view.
}

- (void)didReceiveMemoryWarning
{
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

- (BOOL)shouldAutorotate
{
	//	(iOS 6)
	//	No auto rotating
	return YES;
}

- (NSUInteger)supportedInterfaceOrientations
{
    //	(iOS 6)
    //	Only allow rotation to portrait
    return UIInterfaceOrientationMaskAllButUpsideDown ;//UIInterfaceOrientationMaskPortrait;
}

//- (UIInterfaceOrientation)preferredInterfaceOrientationForPresentation
//{
//	//	(iOS 6)
//	//	Force to portrait
//	return UIInterfaceOrientationPortrait;
//}


-(void)willAnimateRotationToInterfaceOrientation:(UIInterfaceOrientation)toInterfaceOrientation duration:(NSTimeInterval)duration {
    if (toInterfaceOrientation == UIInterfaceOrientationLandscapeLeft ||
        toInterfaceOrientation == UIInterfaceOrientationLandscapeRight) {
        if (!landscape.navigationController) {
        [self pushViewController:landscape animated:NO];            
        }

        
    }
    if (toInterfaceOrientation == UIInterfaceOrientationPortrait ||
        toInterfaceOrientation == UIInterfaceOrientationPortraitUpsideDown) {
            [self popViewControllerAnimated:NO];
    }
}

@end
